<template>
    <div>
        <div class="wrapper">
            <el-carousel height="100vh" direction="vertical" :autoplay="false" trigger="click">
                <el-carousel-item v-for="(item, index) in imgArr" :key="index">
                    <div class="imgs">
                        <img :src="item" class="imgs_img">
                        <div class="btn" v-if="index == 0">
                            <div class="logo">
                                <img src="../assets/guide.png" >
                            </div>
                            <p>技术驱动体育服务创新</p>
                            <el-button @click="visibleLeft = true">
                                用户登录
                            </el-button>
                            <el-drawer v-model="visibleLeft" :show-close="false" class="login">
                                <div class="content">
                                    <div class="user">
                                        <p>系统登录</p>
                                    </div>
                                    <div class="form">
                                        <div class="users"><span>用户名</span><input type="text" v-model="user.name" placeholder="手机号/用户名"></div>
                                        <div class="pwd"><span>密&emsp;码</span><input type="password" v-model="user.password" placeholder="登录密码"></div>
                                        
                                    </div>
                                    <div class="rember"><input type="checkbox">记住密码</div>
                                    <div class="butt"><button @click="login" >登录</button></div>
                                    <div class="bottom">
                                        <span>忘记密码？</span>
                                        <span>还没有账号？</span>
                                        <span @click="visible1Right = true;visibleLeft = false">去申请</span>
                                    </div>
                                </div>
                            </el-drawer>
                            <el-button @click="visible1Right = true">
                                申请入驻
                            </el-button>
                            <el-drawer v-model="visible1Right" :show-close="false" class="login">
                                <div class="content">
                                    <div class="user">
                                        <p>申请入驻</p>
                                    </div>
                                    <div class="form">
                                        <div class="users"><span>用户名</span><input type="text" v-model="admin.name" placeholder="手机号/用户名"></div>
                                        <div class="users"><span>公司名</span><input type="text" v-model="admin.company_name" placeholder="公司名"></div>
                                        <div class="users"><span>手机号</span><input type="text" v-model="admin.tel" placeholder="手机号"></div>
                                        <!-- <div class="pwd"><span>密&emsp;码</span><input type="password" v-model="admin.password" placeholder="登录密码"></div>  -->
                                    </div>
                                    <div class="butt"><button @click="register" >注册</button></div>
                                    <div class="bottom">
                                        <span>&emsp;&emsp;&emsp;&emsp;</span>
                                        <span style="color: rgb(153,153,153);">&emsp;已有账号？</span>
                                        <span style="color:rgb(107,180,255)" @click="visible1Right = false;visibleLeft = true">去登录</span>
                                    </div>
                                </div>
                            </el-drawer>
                        </div>
                        <div class="footer" v-if="index==3">
                            <el-button @click="visibleLeft = true">
                                用户登录
                            </el-button>
                            <el-drawer v-model="visibleLeft" :show-close="false" class="login">
                                <div class="content">
                                    <div class="user">
                                        <p>系统登录</p>
                                    </div>
                                    <div class="form">
                                        <div class="users"><span>用户名</span><input type="text" v-model="user.name" placeholder="手机号/用户名"></div>
                                        <div class="pwd"><span>密&emsp;码</span><input type="password" v-model="user.password" placeholder="登录密码"></div>
                                        
                                    </div>
                                    <div class="rember"><input type="checkbox">记住密码</div>
                                    <div class="butt"><button @click="login" >登录</button></div>
                                    <div class="bottom">
                                        <span>忘记密码？</span>
                                        <span>还没有账号？</span>
                                        <span @click="visible1Right = true;visibleLeft = false">去申请</span>
                                    </div>
                                </div>
                            </el-drawer>
                            <el-button @click="visible1Right = true">
                                申请入驻
                            </el-button>
                            <el-drawer v-model="visible1Right" :show-close="false" class="login">
                                <div class="content">
                                    <div class="user">
                                        <p>申请入驻</p>
                                    </div>
                                    <div class="form">
                                        <div class="users"><span>用户名</span><input type="text" v-model="admin.name" placeholder="手机号/用户名"></div>
                                        <div class="users"><span>公司名</span><input type="text" v-model="admin.company_name" placeholder="公司名"></div>
                                        <div class="users"><span>手机号</span><input type="text" v-model="admin.tel" placeholder="手机号"></div>
                                    </div>
                                    <div class="butt"><button @click="register" >注册</button></div>
                                    <div class="bottom">
                                        <span>&emsp;&emsp;&emsp;&emsp;</span>
                                        <span style="color: rgb(153,153,153);">&emsp;已有账号？</span>
                                        <span style="color:rgb(107,180,255)" @click="visible1Right = false;visibleLeft = true">去登录</span>
                                    </div>
                                </div>
                            </el-drawer>  
                        </div>
                        <div class="copy" v-if="index==3">
                            <p>版权所有：上海天健体育科技发展有限公司 沪ICP备14034023号-2<img src="../assets/1658387374698_ghs.jpg"> </p> 
                            <p>沪公网安备 31011002001672号<img src="../assets/1658387374698_ghs.jpg"></p>  
                        </div>
                    </div>
                </el-carousel-item>
            </el-carousel>
        </div>
    </div>
</template>
<style>
    .login{
        background-color: rgb(64, 63, 63);
    }
    .el-carousel__indicator--vertical .el-carousel__button {
        width: 15px;
        height: 15px;
        border-radius: 50%;
    }
</style>
<style scoped lang="scss">

.wrapper img {
    width: 100%;
}

.imgs {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.btn {
    position: absolute;
    bottom: 100px;
    width: 100%;
    display: flex;
    justify-content: center;
}
.footer{
    position: absolute;
    bottom: 80px;
    width: 100%;
    height: 80px;
    background-color: white;
    display: flex;
    justify-content: center;
    align-items: center;
}
.copy{
    position: absolute;
    bottom: 0;
    width: 100%;
    height: 80px;
    background-color: white;
    text-align: center;
    p{
        img{
            width: 20px;
            height: 20px;
        }
    }
    
}
.footer>button {
    width: 214px;
    height: 55px;
    text-align: center;
    color: #f93;
    background-color: transparent;
    outline: none;
    border: 1px solid #f93;
    padding: 8px 50px;
    border-radius: 10px;
    font-size: 28px;
    cursor: pointer;
}

.footer>button:nth-of-type(2) {
    border-color: #000000;
    color: #000000;
    margin-left: 100px;
}
.btn>p{
    position: absolute;
    top: -40px;
    color: white;
    font-size: 17px;
}
.logo{
    width: 300px;
    height: 300px;
    background-color: rgb(64, 63, 63);
    position: absolute;
    top: -350px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.logo>img{
    width: 85%;
}
.btn>button {
    width: 214px;
    height: 55px;
    text-align: center;
    color: #f93;
    background-color: transparent;
    outline: none;
    border: 1px solid #f93;
    padding: 8px 50px;
    border-radius: 10px;
    font-size: 28px;
    cursor: pointer;
}

.btn>button:nth-of-type(2) {
    border-color: #fff;
    color: #fff;
    margin-left: 100px;
}
.user{
    width: 340px;
    height: 280px;
    background:url(../assets/person.png) no-repeat top center; 
    // background-color: red;
    background-size: 50%;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    margin: 0 auto;
    p{
        font-size: 26px;
        margin-bottom: 20px;
        color: #f93;
        font-weight: bold;
    }
}
.form{
    width: 340px;
    // background-color: red;
    height: 130px;
    margin: 0 auto;
    .users,.pwd{
        width: 320px;
        margin: 0 auto;
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 20px;
        span{
            font-size: 20px;
            color: rgb(255, 255, 255);
        }
        input{
            width: 224px;
            height: 30px;
            border: none;
            border-radius: 6px;
            background-color: #515151;
            padding-left: 8px;
            color: #fff;
        }
    }
}
.butt{
    width: 320px;
    height: 44px;
    margin: 20px auto;
    button{
        width: 100%;
        height: 100%;
        background-color: #f93;
        border-radius: 6px;
        color: white;
        font-size:20px
    }
}
.rember{
    width: 320px;
    margin: 0 auto;
    font-size: 15px;
    color: #939292;
    input{
        width: 20px;
        height: 20px;
        background-color: #515151;
        margin-right: 10px;
    }
}
.bottom{
    width: 260px;
    margin: 0 auto;
    span{
        cursor: pointer;
        color:rgb(107,180,255);
        &:nth-of-type(2){
            color: rgb(153,153,153);
        }
    }
}
</style>
<script  setup>
import { ElButton, ElDrawer,ElMessage } from 'element-plus'
import { reactive, ref } from 'vue';
//登录API接口
import {Login,Register} from '../api/auth'
//创建路由方法
import {useRouter} from 'vue-router'
//创建路由
const router = useRouter()
//启动页照片
const imgArr = reactive(['http://v3-public-images.1yd.me/guide1.png', 'http://v3-public-images.1yd.me/guide2.png',
    'http://v3-public-images.1yd.me/guide3.png', 'http://v3-public-images.1yd.me/guide4.png'])
//登录注册弹出框
const visibleLeft = ref(false)
const visible1Right = ref(false)
//登录的用户信息
const user = ref({
    name:'',
    password:''
})
//注册的用户信息
const admin=ref({
    name:'',
    company_name:'',
    tel:'',
    password:''
})
//登录方法
const login =()=>{
    Login(user.value)
    .then(res=>{
        if(res.data.code==0){
            sessionStorage.setItem('token',res.data.token)
            sessionStorage.setItem('user',JSON.stringify(res.data.user))
            router.push("/admin/home")
        }else{
            ElMessage({
                type: 'error',
                message: res.data.msg,
            })
        } 
    })
    .catch(err=>{
        console.log(err);
    })
}
//注册方法
const register=()=>{
    Register(admin.value)
    .then(res=>{
        if(res.data.code==0){
            alert('注册成功'+res.data.msg)
        }
        console.log(res.data); 
    })
}


</script>